package words;

public class Result {
	private int awl_result;
	private int noun_result;
	private int prep_result;
	private int punt_result;
	private int quot_result;
	private int number_result;
	private int id;
	public Result(int awl_result, int noun_result, int prep_result,
			int punt_result, int quot_result, int number_result) {
		this.awl_result = awl_result;
		this.noun_result = noun_result;
		this.prep_result = prep_result;
		this.punt_result = punt_result;
		this.quot_result = quot_result;
		this.number_result = number_result;
		
	}
	public void setId(int id)
	{
		this.id = id;
	}

	public int getresult(String type_name) {
		if (type_name.equals("awl")) {
			return this.awl_result;
		} else if (type_name.equals("noun")) {
			return this.noun_result;
		} else if (type_name.equals("prep")) {
			return this.prep_result;
		} else if (type_name.equals("punt")) {
			return this.punt_result;
		} else if (type_name.equals("quot")) {
			return this.quot_result;
		} else if (type_name.equals("number")) {
			return this.number_result;
		}
		return -1;

	}

	public int countRate(){
		int rate = 0;
		if(this.awl_result > 3)
			rate += 15;
		if(this.noun_result > 2)
			rate += 20;
		if(this.prep_result > 3)
			rate += 15;
		if(this.punt_result > 2)
			rate += 5;
		if(this.quot_result > 1)
			rate += 30;
		if(this.number_result > 3)
			rate += 15;
		
		return rate;
	}
	
	// Function for output each article's different condition result
	public String toString() {
		int rate;
		rate = countRate();
		String information;
		if( rate < 50){
				information = String.format(
				"<tr><td>The article %d	</td>" +
				"<td> The awl result is %d </td>" +
				"<td> The noun result is %d </td>" +
				"<td> The prep result is %d </td>" +
				"<td> The punt result is %d </td>" +
				"<td> The quot result is %d </td>" +
				"<td> The number result is %d </td>" +
				"<td> The similar rate is: %d </td>" +
				"<td> <a style=\"color:green\">Non Plagiarism </a></td></tr>",this.id
				, this.awl_result,
				this.noun_result, this.prep_result, this.punt_result,
				this.quot_result, this.number_result, rate);
		}
		else
		{
				information = String.format(
				"<tr><td>The article %d	</td>" +
				"<td> The awl result is %d </td>" +
				"<td> The noun result is %d </td>" +
				"<td> The prep result is %d </td>" +
				"<td> The punt result is %d </td>" +
				"<td> The quot result is %d </td>" +
				"<td> The number result is %d </td>" +
				"<td> The similar rate is: %d </td>" +
				"<td> <a style=\"color:red\">Warning! Plagiarism!!!!!! </a></td></tr>",this.id
				, this.awl_result,
				this.noun_result, this.prep_result, this.punt_result,
				this.quot_result, this.number_result, rate);
		}
		return information;
	}
}
